package com.ruoyi.common.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5;
import com.ruoyi.common.dict.Demo;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author huyunqiang
 * @Description
 * @Date 2022/8/17 9:50
 *  https://www.bookstack.cn/read/hutool/4071a2a690b9571a.md
 **/
public class DESCrypt {

    public static void main(String[] args) {
        //md5 加密
/*        MD5 md5 = SecureUtil.md5();
        System.out.println(md5.digestHex("ssssss","UTF-8"));

        //时间转换
        String a = "2017-05-06 11:11:00";
        Date value = Convert.toDate(a);
        System.out.println(value);

        //类型转换
        String strNum = NumberUtil.toStr(new BigDecimal(4.99));

        //当前时间
        Date date4 = DateUtil.date();
        //当前时间
        Date date2 = DateUtil.date(Calendar.getInstance());
        //当前时间
        Date date3 = DateUtil.date(System.currentTimeMillis());
        //当前时间字符串，格式：yyyy-MM-dd HH:mm:ss
        String now = DateUtil.now();
        //当前日期字符串，格式：yyyy-MM-dd
        String today= DateUtil.today();
        //----------------------格式化日期输出
        String dateStr = "2017-03-01";
        Date date = DateUtil.parse(dateStr);
    //结果 2017/03/01
        String format = DateUtil.format(date, "yyyy/MM/dd");
    //常用格式的格式化，结果：2017-03-01
        String formatDate = DateUtil.formatDate(date);
    //结果：2017-03-01 00:00:00
        String formatDateTime = DateUtil.formatDateTime(date);
    //结果：00:00:00
        String formatTime = DateUtil.formatTime(date);*/


/*        String dateStr = "2017-03-01 22:33:23";
        Date date = DateUtil.parse(dateStr);
//一天的开始，结果：2017-03-01 00:00:00
        Date beginOfDay = DateUtil.beginOfDay(date);
//一天的结束，结果：2017-03-01 23:59:59
        Date endOfDay = DateUtil.endOfDay(date);

        System.out.println(DateUtil.beginOfQuarter(date));*/


        String dateStr = "2017-03-01 22:33:23";
        Date date = DateUtil.parse(dateStr);
//结果：2017-03-03 22:33:23
        Date newDate = DateUtil.offset(date, DateField.DAY_OF_MONTH, 2);
//常用偏移，结果：2017-03-04 22:33:23
        DateTime newDate2 = DateUtil.offsetDay(date, 3);
//常用偏移，结果：2017-03-01 19:33:23
        DateTime newDate3 = DateUtil.offsetHour(date, -3);

        boolean isEmail = Validator.isEmail("loolly@gmail.com");
       Validator.isMobile("18863736980");
        System.out.println(Validator.isMobile("188637369810"));

        //map-bean
        Demo demo = new Demo();
        demo.setName("hyq");
        demo.setSex("N");
        demo.setStatus(0);
        Map<String, Object> map = BeanUtil.beanToMap(demo);

        Map<String,Object> objectMap = new HashMap<>();
        objectMap.put("name","ssss");
        objectMap.put("sex","b");
        objectMap.put("status","1");
        Demo demo2 = new Demo();
        BeanUtil.fillBeanWithMap(objectMap,demo2,true);



    }
}
